/**
 * Created by Administrator on 2017/3/13 0013.
 */




Page7={
    Create:function() {
        var page = {};
        var whole = new PIXI.DisplayObjectContainer();

        var whiteBG=new PIXI.Graphics();
        whiteBG.beginFill(0xffffff,1);
        whiteBG.drawRect(0,0,740,1136);

        var head1=PSP("page7_1");
        var head2=PSP("page7_2");
        var head3=PSP("page7_3");
        var head4=PSP("page7_4");
        var head5=PSP("page7_5");
        var head6=PSP("page7_6");
        var head7=PSP("page7_7");

        var arr_gold=[];
        var arr_blur=[];

        for(var z=1;z<=6;z++){
            var hanzi=PSP("pic"+z);
            arr_gold.push(hanzi);
            hanzi.anchor.set(0.5);

            var blur=new PIXI.filters.BlurFilter();
            blur.blur=0;
            arr_blur.push(blur);
        }

        whole.addChild(whiteBG);
        for(var z=0;z<arr_gold.length;z++) {
            whole.addChild(arr_gold[z]);
            arr_gold[z].alpha=0;
            var xx,yy,sc;
            var xv,yv;
            switch(z){
                case 0:xx=8;yy=62;sc=0.8;xv=10;yv=-20;break;
                case 1:xx=306;yy=125;sc=0.8;xv=0;yv=4;break;
                case 2:xx=458;yy=-102;sc=1.2;xv=10;yv=10;break;
                case 3:xx=115;yy=467;sc=0.9;xv=-30;yv=30;break;
                case 4:xx=-27;yy=731;sc=1.2;xv=-40;yv=30;break;
                case 5:xx=487;yy=680;sc=0.8;xv=10;yv=10;break;
            }
            arr_gold[z].x=xx+arr_gold[z].width/2;arr_gold[z].y=yy+arr_gold[z].height/2;
            var aa=Math.random()*2;
            TweenMax.to(arr_gold[z].scale,2+aa,{delay:0.5*z,x:sc,y:sc,yoyo:true,repeat:-1,ease:Cubic.easeInOut});
            TweenMax.to(arr_gold[z],2+aa,{delay:0.5*z,x:arr_gold[z].x+xv,y:arr_gold[z].y+yv,yoyo:true,repeat:-1,ease:Cubic.easeInOut});
        }
        whole.addChild(head1);
        whole.addChild(head2);
        whole.addChild(head3);
        whole.addChild(head4);
        whole.addChild(head5);
        whole.addChild(head6);
        whole.addChild(head7);





        var bl=false;



        page.DoIt=function(){
            if(bl){
            for(var z=0;z<arr_gold.length;z++){

                if(arr_gold[z].scale.x==1){
                    var randomTime=Math.random();
                    TweenMax.to(arr_gold[z],1+randomTime,{alpha:1,x:740/2+randomTime*100-50,y:1136/2-randomTime*100-50});
                    TweenMax.to(arr_gold[z].scale,1.5+randomTime,{x:0,y:0,alpha:0,ease:Cubic.easeInOut});
                    //guagua   // TweenMax.to(arr_blur[z],1+randomTime,{blur:0,alpha:0,ease:Cubic.easeInOut});
                }
                else if(arr_gold[z].scale.x==0){
                    arr_gold[z].scale.x=1;arr_gold[z].scale.y=1;
                    //guagua//   arr_blur[z].blur=5;
                    var a=Math.random()*200;
                    switch (Math.round(Math.random()*3)){
                        case 0: arr_gold[z].x=0-a;arr_gold[z].y=0;break;
                        case 1: arr_gold[z].x=0-a;arr_gold[z].y=1136;break;
                        case 2: arr_gold[z].x=740+a;arr_gold[z].y=0;break;
                        case 3: arr_gold[z].x=740+a;arr_gold[z].y=1136;break;
                    }

                }

            }
            }
        }

        head1.x=208;head1.y=419;
        head2.x=343;head2.y=434;
        head3.x=184;head3.y=491;
        head4.anchor.set(0.5);
        head4.x=267+head4.width/2;head4.y=605+head4.height/2;
        head5.x=211;head5.y=701;
        head6.x=238;head6.y=746;
        head7.anchor.set(0.5);
        head7.x=293+head7.width/2;head7.y=71+head7.height/2;

        head1.alpha=0;
        head2.alpha=0;
        head3.alpha=0;
        head4.alpha=0;
        head5.alpha=0;
        head6.alpha=0;
        head7.alpha=0;

        head1.y=419-30;
        head2.x=343+35;
        head3.x=184-30;
        head4.y=636-30;
        head4.scale.set(2);
        head5.y=701-20;
        head6.y=746-20;
        head7.scale.set(2);

        page.In=function(){

            TweenMax.to(head1,0.7,{delay:0.0,alpha:1,y:419,ease:Cubic.easeOut});
            TweenMax.to(head2,0.7,{delay:0.2,alpha:1,x:343,ease:Cubic.easeOut});
            TweenMax.to(head3,0.7,{delay:0.4,alpha:1,x:184,ease:Cubic.easeOut});


            TweenMax.to(head4,0.7,{delay:0.6,alpha:1,y:636,ease:Cubic.easeOut});
            TweenMax.to(head4.scale,0.7,{delay:0.6,x:1,y:1,ease:Cubic.easeOut});

            TweenMax.to(head5,0.7,{delay:0.8,alpha:1,y:701,ease:Cubic.easeOut});
            TweenMax.to(head6,0.7,{delay:0.9,alpha:1,y:746,ease:Cubic.easeOut});

            TweenMax.to(head7.scale,0.7,{delay:1,x:1,y:1,ease:Cubic.easeOut});
            TweenMax.to(head7,0.7,{delay:1,alpha:1,ease:Cubic.easeOut});

            for(var z=0;z<arr_gold.length;z++){
                TweenMax.to(arr_gold[z],0.7,{delay:1.2+z*0.2,alpha:1,ease:Cubic.easeOut});
            }

            setTimeout(function(){
                bl=true;
            },1200)
        }
        page.Out=function(){
            for(var z=0;z<arr_gold.length;z++){
                TweenMax.to(arr_gold[z],1,{alpha:0,ease:Cubic.easeOut});
            }
        }

        page.ReturnWhole=function(){
            return whole;
        };

        return page;
    }
}
